# @Time:2021/6/10 16:21
# @Author:5120195554王欣霏
# -*- coding = utf-8 -*-

import os
import sys
import pygame
from pygame.constants import QUIT

pygame.init()
back_img_path = os.path.join('../resource', 'img', 'temple.jpg')
back_surface = pygame.image.load(back_img_path)
screen = pygame.display.set_mode((800, 600), 0, 32)
pygame.display.set_caption("场景变换")
alpha = 0  # alpha值越小越透明
while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    back_surface.set_alpha(alpha)
    screen.fill((0, 0, 0))  # 为了效果更明显
    screen.blit(back_surface, (0, 0))
    alpha += 5
    pygame.time.delay(30)  # 时间延迟
    pygame.display.update()
